package de.lulusoft.anothertorrent.gui.views.Providers;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;

import de.lulusoft.anothertorrent.core.servers.Server;
import de.lulusoft.anothertorrent.core.servers.ServerManager;
import de.lulusoft.anothertorrent.gui.AnotherTorrentGui;

public class ServerViewLabelProvider implements ILabelProvider {
	
	private static Image serverImage = null;

	@Override
	public Image getImage(Object element) {
		if (element instanceof Server)
		{
			if (serverImage == null)
				serverImage = AnotherTorrentGui.createImage("server.png");
			return serverImage;
		}
		return null;
	}

	@Override
	public String getText(Object element) {
		if (element instanceof ServerManager)
		{
			return "ServerManager";
		}
		else if (element instanceof Server)
		{
			return ((Server)element).getName();
		}
		return "";
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
	}

}
